/*
3.Service层：业务层 控制业务
业务模块的逻辑应用设计，和DAO层一样都是先设计接口，再创建要实现的类，然后在配置文件中进行配置其实现的关联。接下来就可以在service层调用接口进行业务逻辑应用的处理。

好处：封装Service层的业务逻辑有利于业务逻辑的独立性和重复利用性。
 */
package com.dfrobot.demo.service;


import com.dfrobot.demo.dao.AddressMapper;
import com.dfrobot.demo.dao.UserMapper;
import com.dfrobot.demo.domain.entity.Address;
import com.dfrobot.demo.domain.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
//@Service用于标注业务层组件
@Service
public class AddressService {
    @Autowired
    private AddressMapper addressMapper;
    // 生成的model      调用数据库DB类型

    //获取地址类
    public List<Address> getAddressList() {
        List<Address> addressList = this.addressMapper.selectAll();
        return addressList;
    }


    public List<Address> addressSelect(int id) {
        Example example = new Example(Address.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andLike("firstname", "%adair%");
        List<Address> addressList = this.addressMapper.selectByExample(example);
        return addressList;
    }


    //从DAO层获取 获取所有地址的行数
    public  String getAddressCount(){
        String addressCount = addressMapper.getAddressCount();
        //String addressCount = "10";
        return addressCount;
    }

    /*
     * 根据表名查询字段值和数据库字段对应
     * @return
    */
    /*public List<Map<String,Object>> findFieldByTableName(String tableName){
        String sql="select * from t_fieldorder where table_name "+" = " +"'"+tableName+"'" ;
        List<Map<String,Object>> list = addressMapper.findFieldByTableName(sql);
        return list;
    }*/




}


